﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jzy.Workflow.Flow;
using Jzy.Workflow.Node;
using Jzy.Workflow.Form;

namespace Jzy.Workflow.Task
{
    public partial class FlowTaskInfo
    {
        public FlowTaskInfo()
        {
            GetFlowInfo = id => null;
        }

        public Func<object, FlowInfo> GetFlowInfo;
        private FlowInfo _flowInfo;
        public FlowInfo FlowInfo
        {
            get
            {
                if (_flowInfo == null)
                {
                    _flowInfo = GetFlowInfo(FlowID);
                }
                return _flowInfo;
            }
            set
            {
                _flowInfo = value;
            }
        }

        public Func<int, int, FlowNodeInfo> GetNodeInfo;
        private FlowNodeInfo _receiveNodeInfo;
        public FlowNodeInfo ReceiveNodeInfo
        {
            get
            {
                if (_receiveNodeInfo == null)
                {
                    _receiveNodeInfo = GetNodeInfo(this.ReceiveNodeID, FormID);
                }
                return _receiveNodeInfo;
            }
            set
            {
                _receiveNodeInfo = value;
            }
        }

        //private FlowNodeInfo _sendNodeInfo;
        //public FlowNodeInfo SendNodeInfo
        //{
        //    get
        //    {
        //        if (_sendNodeInfo == null)
        //        {
        //            _sendNodeInfo = GetNodeInfo(this.SendNodeID, FormID);
        //        }
        //        return _sendNodeInfo;
        //    }
        //    set
        //    {
        //        _sendNodeInfo = value;
        //    }
        //}


        public Func<object, FlowFormInfo> GetFormInfo;
        private FlowFormInfo _formInfo;
        public FlowFormInfo FormInfo
        {
            get
            {
                if (_formInfo == null)
                {
                    _formInfo = GetFormInfo(FormID);
                }
                return _formInfo;
            }
            set
            {
                _formInfo = value;
            }
        }

        public Func<object, FlowTaskInfo> GetTaskInfo;
        private FlowTaskInfo _preTaskInfo;
        public FlowTaskInfo PreTaskInfo
        {
            get
            {
                if (_preTaskInfo == null)
                {
                    _preTaskInfo = GetTaskInfo(this.PreTaskID);
                }
                return _preTaskInfo;
            }
            set
            {
                _preTaskInfo = value;
            }
        }

        public Func<object, List<FlowTaskInfo>> GetNextTaskInfos;
        private List<FlowTaskInfo> _nextTaskInfos;
        public List<FlowTaskInfo> NextTaskInfos
        {
            get
            {
                if (_nextTaskInfos == null)
                {
                    _nextTaskInfos = GetNextTaskInfos(this.ID);
                }
                return _nextTaskInfos;
            }
            set
            {
                _nextTaskInfos = value;
            }
        }


    }
}
